package com.sluggard.security.manage.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sluggard.mp.model.entity.StandardAuditEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 用户管理
 * </p>
 *
 * @author lizheng
 * @since 2024-04-28
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("sys_user")
@Schema(name = "UserEntity", description = "用户管理")
public class UserEntity extends StandardAuditEntity {

    private static final long serialVersionUID = 1L;

    @Schema(description = "最后选择角色")
    @TableField("role_id")
    private Long roleId;

    @Schema(description = "用户名")
    @TableField("username")
    private String username;

    @Schema(description = "姓名")
    @TableField("real_name")
    private String realName;

    @Schema(description = "昵称")
    @TableField("nick_name")
    private String nickName;

    @JsonIgnore
    @Schema(description = "密码")
    @TableField("password")
    private String password;

    @Schema(description = "类型{1:超级管理员,2:普通管理员}")
    @TableField("type")
    private Integer type;

    @Schema(description = "电子邮件")
    @TableField("email")
    private String email;

    @Schema(description = "手机号码")
    @TableField("mobile_no")
    private String mobileNo;

    @Schema(description = "账户过期时间")
    @TableField(value = "expiration_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expirationTime;

    @Schema(description = "状态{1:正常,0:停用}")
    @TableField("status")
    private Integer status;

    @Schema(description = "描述")
    @TableField("descn")
    private String descn;

    @TableField(value = "roles", exist = false)
    private List<RoleEntity> roles;
}
